{include file="public/header" /}
<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-body ">
          <fieldset id="searchFieldset_currentTableRenderId" class="table-search-fieldset">
            <legend>条件搜索</legend>
            <form class="layui-form layui-form-pane form-search">
              <div class="layui-form-item layui-inline">
                <label class="layui-form-label">搜索</label>
                <div class="layui-input-inline">
                  <input type="text" name="title" placeholder="订单编号/收货信息/备注" value="{:input('get.title')}"
                    autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item layui-inline">
                <label class="layui-form-label">下单时间</label>
                <div class="layui-input-inline">
                  <input type="text" name="starttime" placeholder="下单时间" id="starttime"
                    value="{:input('get.starttime')}" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item layui-inline">
                <label class="layui-form-label">截止时间</label>
                <div class="layui-input-inline">
                  <input type="text" name="endtime" placeholder="截止时间" id="endtime" value="{:input('get.endtime')}"
                    autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item layui-inline">
                <label class="layui-form-label">订单状态</label>
                <div class="layui-input-inline">
                  <select name="status">
                    <option value=""></option>
                    <option value="1" {if !empty(input('get.status')) && input('get.status')==1}selected{/if}>待审核
                    </option>
                    <option value="2" {if !empty(input('get.status')) && input('get.status')==2}selected{/if}>待出库
                    </option>
                    <option value="3" {if !empty(input('get.status')) && input('get.status')==3}selected{/if}>待发货
                    </option>
                    <option value="4" {if !empty(input('get.status')) && input('get.status')==4}selected{/if}>待收货
                    </option>
                    <option value="5" {if !empty(input('get.status')) && input('get.status')==5}selected{/if}>已收货
                    </option>
                    <option value="6" {if !empty(input('get.status')) && input('get.status')==6}selected{/if}>已取消
                    </option>
                  </select>
                </div>
              </div>
              <div class="layui-form-item layui-inline">
                <label class="layui-form-label">付款状态</label>
                <div class="layui-input-inline">
                  <select name="review">
                    <option value=""></option>
                    <option value="1" {if !empty(input('get.review')) && input('get.review')==1}selected{/if}>待支付
                    </option>
                    <option value="2" {if !empty(input('get.review')) && input('get.review')==2}selected{/if}>待审核
                    </option>
                    <option value="3" {if !empty(input('get.review')) && input('get.review')==3}selected{/if}>已支付
                    </option>
                  </select>
                </div>
              </div>
              <div class="layui-form-item layui-inline">
                <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="sreach">搜索</button>
              </div>
            </form>
          </fieldset>
        </div>
        <div class="layui-card-header">
          <a title="审核订单" onclick="delAll('/order/list_edit','3','2')" href="javascript:;"
            class="layui-btn layui-btn-normal layui-btn-sm">
            审核订单
          </a>
          <a title="出库订单" onclick="delAll('/order/list_edit','3','3')" href="javascript:;"
            class="layui-btn layui-btn-normal layui-btn-sm">
            出库订单
          </a>
          <a title="发货订单" onclick="delAll('/order/list_edit','3','4')" href="javascript:;"
            class="layui-btn layui-btn-normal layui-btn-sm">
            发货订单
          </a>
          <a title="收货订单" onclick="delAll('/order/list_edit','3','5')" href="javascript:;"
            class="layui-btn layui-btn-normal layui-btn-sm">
            收货订单
          </a>
          <a title="添加" onclick="open_add('添加','/order/listdetail')" href="javascript:;" class="layui-btn layui-btn-sm">
            添加订单
          </a> 数据：<strong id="count">{$list->total()}</strong> 条
        </div>
        <div class="layui-card-body layui-table-body layui-table-main">
          <table class="layui-table layui-form">
            <thead>
              <tr>
                <th>
                  <input type="checkbox" lay-filter="checkall" name="" lay-skin="primary">
                </th>
                <th>
                  <div class="layui-table-cell">ID</div>
                </th>
                <th>
                  <div class="layui-table-cell">订单编号</div>
                </th>
                <th>
                  <div class="layui-table-cell">下单时间</div>
                </th>
                <th>
                  <div class="layui-table-cell">客户名</div>
                </th>
                <th>
                  <div class="layui-table-cell">联系电话</div>
                </th>
                <th>
                  <div class="layui-table-cell">订单金额</div>
                </th>
                <th>
                  <div class="layui-table-cell">订单状态</div>
                </th>
                <th>
                  <div class="layui-table-cell">收款状态</div>
                </th>
                <th>
                  <div class="layui-table-cell">收货地址</div>
                </th>
                <th>
                  <div class="layui-table-cell">操作</div>
                </th>
              </tr>
            </thead>
            <tbody>
              {foreach $list as $v}
              <tr>
                <td>
                  <input type="checkbox" name="id" value="{$v.id|default='0'}" lay-skin="primary">
                </td>
                <td>
                  <div class="layui-table-cell">{$v.id|default=''}</div>
                </td>
                <td>
                  <div class="layui-table-cell">{$v.ordersn|default='--'}</div>
                </td>
                <td>
                  <div class="layui-table-cell">{$v.created|default='--'}</div>
                </td>
                <td>
                  <div class="layui-table-cell">{$v.name|default='--'}</div>
                </td>
                <td>
                  <div class="layui-table-cell">{$v.mobile|default='--'}</div>
                </td>
                <td>
                  <div class="layui-table-cell">{$v.total|default='--'}</div>
                </td>
                <td>
                  <div class="layui-table-cell">{$v.status_text|default=''}</div>
                </td>
                <td>
                  <div class="layui-table-cell">{$v.review_text|default=''}</div>
                </td>
                <td>
                  <div class="layui-table-cell">
                    {$v.province|default=''}{$v.city|default=''}{$v.area|default=''}{$v.address|default=''}</div>
                </td>
                <td class="layui-table-col-special">
                  <div class="layui-table-cell">
                    <a title="查看" onclick="open_add('查看','/order/list_edit?id={$v.id}')" href="javascript:;"
                      class="layui-btn layui-btn-sm">
                      查看
                    </a>
                    {switch v.status}
                    {case 1}
                    <a title="查看" onclick="open_add('查看','/order/list_edit?id={$v.id}')" href="javascript:;"
                      class="layui-btn layui-btn-sm">
                      订单审核
                    </a>
                    {/case}
                    {case 2}
                    <a title="查看" onclick="open_add('查看','/order/list_edit?id={$v.id}')" href="javascript:;"
                      class="layui-btn layui-btn-sm">
                      订单出库
                    </a>
                    {/case}
                    {case 3}
                    <a title="查看" onclick="open_add('查看','/order/list_edit?id={$v.id}')" href="javascript:;"
                      class="layui-btn layui-btn-sm">
                      订单发货
                    </a>
                    {/case}
                    {case 4}
                    <a title="查看" onclick="open_add('查看','/order/list_edit?id={$v.id}')" href="javascript:;"
                      class="layui-btn layui-btn-sm">
                      完成订单
                    </a>
                    {/case}
                    {case 5}
                    订单已完成
                    {/case}
                    {case 5}
                    订单已取消
                    {/case}
                    {/switch}
                  </div>
                </td>
              </tr>
              {/foreach}
            </tbody>
          </table>
        </div>
        <div class="layui-card-body">
          <div class="page">
            {$list->render()|raw}
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</body>
{include file="public/footer"}
<script>
  layui.use(['laydate', 'form'], function () {
    var laydate = layui.laydate;
    var form = layui.form;
    // 监听全选
    form.on('checkbox(checkall)', function (data) {

      if (data.elem.checked) {
        $('tbody input').prop('checked', true);
      } else {
        $('tbody input').prop('checked', false);
      }
      form.render('checkbox');
    });
  });
  function delAll(url, type, status) {
    var ids = [];
    // 获取选中的id 
    $('tbody input').each(function (index, el) {
      if ($(this).prop('checked')) {
        ids.push($(this).val())
      }
    });
    if (ids.length <= 0) {
      layer.msg('请选择操作选项', { icon: 2, time: 1000 });
      return true;
    }
    layer.confirm('确认要这样操作吗？', function (index) {
      //捉到所有被选中的，发异步进行删除

      $.post(url, { id: ids, type: type, status: status, all: 1 },
        function (data) {
          if (data.status == 0) {
            layer.msg(data.msg, { icon: 1, time: 1000 }, function () {
              // 获得frame索引
              location.reload();
              layer.close(index);
            });
          } else {
            layer.msg(data.msg, { icon: 2, time: 1000 });
          }
        }, "json"
      );
      // $(".layui-form-checked").not('.header').parents('tr').remove();
    });
  }
  function open_dels(obj, url, id, field, status) {
    var ids = [id];
    layer.confirm("确认要执行该操作吗？", function (index) {
      //发异步删除数据
      $.post(
        url,
        { id: ids, field: field, status: status },
        function (data) {
          if (data.status == 0) {
            layer.msg(data.msg, { icon: 1, time: 1000 }, function () {
              // 获得frame索引
              location.reload();
              layer.close(index);
            });
          } else {
            layer.msg(data.msg, { icon: 2, time: 1000 });
          }
        },
        "json"
      );
    });
  }
</script>
<script>
  layui.use('laydate', function () {
      var laydate = layui.laydate;
      //执行一个laydate实例
      laydate.render({
          elem: '#starttime' //指定元素
          , type: 'datetime'

      });
  });
  layui.use('laydate', function () {
      var laydate = layui.laydate;
      //执行一个laydate实例
      laydate.render({
          elem: '#endtime' //指定元素
          , type: 'datetime'

      });
  });
</script>
</html>